package com.example.footballsystem.service;

import com.example.footballsystem.entity.Tran;
import com.example.footballsystem.mapper.TeamMapper;
import com.example.footballsystem.mapper.TranMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.core.Local;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.Date;
import java.util.List;
@Slf4j
@Service
public class TranSercice {
    @Autowired
    TranMapper tranMapper;
    public List<Tran> getAllTran(){
        return tranMapper.selectAllTran();
    }
    public List<Tran> getTranByUserID(String userID){
        return tranMapper.selectTranByAccount(userID);
    }
    public List<Tran> getUserFinishTran(Boolean isFinish,String userID){
        return tranMapper.selectUserFinishTran(userID,isFinish);
    }
    public Boolean addTran(Tran t){
        LocalDate date = LocalDate.now();
        t.setTime(date);
        return tranMapper.addTran(t);
    }
    public Boolean finishTran(String uerID,String title){
        return tranMapper.finishTran(uerID,title);
    }
    //获取用户当天训练
    public List<Tran> getTodayTran(String userID){
        LocalDate time = LocalDate.now();
        log.info("123123222 "+time.toString());
        return tranMapper.selectTodayTran(userID);
    }
    //获取用户当天完成或未完成的训练
    public List<Tran> getTodayFinishTran(String userID, Boolean isFinish){
        //Date time = new Date(System.currentTimeMillis());
        LocalDate time = LocalDate.now();
        return tranMapper.selectTodayUserFinishTran(userID,time,isFinish);
    }
    public List<Integer> getTranCount(){
        return tranMapper.getTranCount();
    }
    public Integer count(){
        return tranMapper.count();
    }
}

